<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link rel="stylesheet" href="resources/css/style.css" type="text/css"/>
<style type="text/css">
#topT td {
	border: 1px solid #eeeeee;
}

#topT tr td:first-child {
	background:#444444;
	color:#eeeeee;
}

input[type=button] {
	width:120px;
	height:26px;
}
</style>

<script src="resources/js/jquery-1.9.1.js"></script>
<script src="resources/js/jquery.json-2.4.js"></script>
<script type="text/javascript">
$(function() {
	$(":checkbox").css("position", "relative")
		.css("top", "5px");
});

function sendReply() {
	$("input[type=button]").attr("disabled", true);
	$("textarea[name=reply]").css("display", "none");
	$("#msg").css("display", "block");
	$("#msg").html("답변을 보내는 중입니다. 잠시만 기다려 주세요.");
	
	var jsonParam = {
		ask_no: $("input[name=ask_no]").val(),
		reply: $("textarea[name=reply]").val(),
		giveGgong: $("input[name=giveGgong]:checkbox").prop("checked")
	};
	
	$.ajax({
		url: "ask_reply.ga",
		type: "post",
		dataType: "html",
		data: {
			jsonParam: $.toJSON(jsonParam)
		},
		success: function(data) {
			if(data == "1") {
				alert("성공적으로 답변을 보냈습니다.");
				self.close();
			}else{
				alert("오류가 발생하였습니다. 다시 시도해 주십시오.");
				$("input[type=button]").attr("disabled", false);
				$("textarea[name=reply]").css("display", "block");
				$("#msg").css("display", "none");
			}
		},
		error: function() {
			alert("오류");
		}
	});
}

</script>

<title>꽁알 : Administrator - 1:1 문의 내용 보기</title>
</head>
<body>

<div style="text-align:center;border:1px solid #eeeeee;">
<table id="topT" align="center" cellspacing="0" cellpadding="5" style="width:420px;">
	<tr>
		<td>날짜</td>
		<td>${resultClass.regdate }</td>
	</tr>
	<tr>
		<td>ID</td>
		<td>${resultClass.user_id }</td>
	</tr>
	<tr>
		<td>E-Mail</td>
		<td>${resultClass.email }</td>
	</tr>
	<tr>
		<td>질문 분류</td>
		<td>${resultClass.type }</td>
	</tr>
</table>

<!-- 꽁 지급 -->
<table align="center" style="text-align:right;width:420px;">
<tr><td>
<c:if test="${resultClass.type == '버그신고하기' }">
1000 꽁 지급하기 <input type="checkbox" name="giveGgong" checked/>
</c:if>
<c:if test="${resultClass.type != '버그신고하기' }">
<input type="checkbox" name="giveGgong" style="display:none;"/>
<br/>
</c:if>
</td></tr>
</table>

<input type="text" style="width:420px;height:26px;margin:2px;padding:2px;background:#eeeeee;border:1px solid #aaaaaa;" value="${resultClass.subject }" readonly/>
<textarea rows="10" cols="66" style="resize:none;width:420px;background:#eeeeee;" readonly>${resultClass.contents }</textarea>
<br/>

<input type="hidden" name="ask_no" value="${resultClass.ask_no }"/>
<textarea name="reply" rows="10" cols="66" style="resize:none;width:420px;"></textarea>

<div id="msg" style="display:none;margin:75px;"></div>

<br/>

<input type="button" value="답변 보내기" onclick="sendReply()"/>
<input type="button" value="이전" onclick="history.back(-1)"/>

</div>

</body>
</html>